<template>
	<view :class="!tabflag ? 'faburenwu_bg':'lishifabu_bg'" class="container">
		<view class="statusBarHeight">
		</view>
		<view class="bg"></view>
		<view style="height: 100%;margin-top: -240rpx;display: flex;flex-flow: column; align-items: center;">
			<view class="bgHead">
				<text>
				</text>
				<view class="redD" v-if="redDot"></view>
				<image src="http://images.linglinggong.net/icon1/msg.png" mode="aspectFill" @click="getMessage"></image>
			</view>
			<view class="banner">
				<!-- <uni-swiper-dot :mode="'round'" :info="bannerImgs" :dotsStyles="dotsStyles" :current="currents">
					<swiper class="swiper" @change="change" circular="true" autoplay="true" interval="4000"
						duration="2000">
						<swiper-item v-for="(item , index) in bannerImgs" :key="index">
							<image :src="item.img" @click="tiaozhuan(item.path)" mode="aspectFill">
							</image>
						</swiper-item>
					</swiper>
				</uni-swiper-dot> -->
				<uni-swiper-dot :mode="'round'" :info="configBanner" :dotsStyles="dotsStyles" :current="currents">
					<swiper class="swiper" @change="change" :circular="true" :autoplay="true" :interval="3500"
						:duration="200">
						<swiper-item v-for="(item , index) in configBanner" :key="item.id">
							<image :src="imgPath+item.img" @click="tiaozhuan2(item.act)" mode="aspectFill">
							</image>
						</swiper-item>
					</swiper>
				</uni-swiper-dot>
			</view>
			<view class="tabDiv" :style="{paddingTop: tabrHei + 'rpx'}">
				<view class="tabLeft" @click="tabflag=!tabflag">
					<text class="tabLeftText" v-if="tabflag">发布任务</text>
					<image v-if="!tabflag" class="tabLeftImg" src="http://images.linglinggong.net/icon1/faburenwu.png"
						mode="aspectFill"></image>
				</view>
				<view class="tabRight" @click="tabflag=!tabflag">
					<text class="tabRightText" v-if="!tabflag" @click="getJobList()">历史发布</text>
					<image v-if="tabflag" class="tabRightImg" src="http://images.linglinggong.net/icon1/fabulishi.png"
						mode="aspectFill"></image>
				</view>
			</view>
			<view class="jobList"
				:style="{'background-color': !tabflag ? '#FFF' : this.iswhite || isShowNullList ? '#FFF' : '#F2F2F2'}">
				<view class="fakejobList" v-if="!tabflag">
					<view class="fakeJob anim-opacity" v-if="!tabflag">
						{{fakeInfo[0]}}分钟前{{fakeInfo[1]}}**已接取{{fakeInfo[2]}}任务
					</view>
					<view class="fakeJob anim-opacity1" v-if="!tabflag" style="position: absolute">
						{{fakeInfo[3]}}分钟前{{fakeInfo[4]}}**已接取{{fakeInfo[5]}}任务
					</view>
					<view class="fakeJob anim-opacity2" v-if="!tabflag" style="position: absolute">
						{{fakeInfo[6]}}分钟前{{fakeInfo[7]}}**已接取{{fakeInfo[8]}}任务
					</view>
				</view>
				<view class="jobLogo" @click="sendJob()" v-if="isShowNullList || !tabflag">
					<view>
						<view><text>发任务</text>
							<text>这里发布新的零工任务</text>
						</view>
						<image src="http://images.linglinggong.net/icon1/jiantou.png" mode="aspectFill"></image>
					</view>
				</view>
				<view class="aroundPeople" v-if="!tabflag">
					<text class="aroundPeopleTest">您周围有</text>
					<text class="aroundPeopleTestNum">{{userNum}}</text>
					<text class="aroundPeopleTest">雇员等待您发单</text>
				</view>
				<view class="aroundPeople" v-if="isShowNullList&&tabflag">
					<text class="aroundPeopleTest">你还没有发布过任务</text>
				</view>
				<!-- 零工列表  -->
				<view v-if="!isShowNullList&&tabflag">
					<view class="job-info" v-for="item in jobLists" :key="item.id"
						@click="handleOpenPage(item.id, item.status)">
						<view>
							<view>
								<view
									style="width: 10rpx; height: 40rpx; background: #FCC928; margin-top: 3rpx; border-radius: 0 5rpx 5rpx 0;">
								</view>
								<text>{{item.name.length>9 ? item.name.slice(0,9)+'...' : item.name}}</text>
							</view>
							<!-- 状态栏 -->
							<view class="status">
								<text class="default"
									:class="[ item.showDay=='今天' ? 'jintian' : item.showDay=='昨天' ? 'zuotian' : '']">{{ item.showDay }}</text>
							</view>
						</view>
						<view>
							<view>
								<text>{{ item.reward }}</text>
								<text>金额（{{ item.taskType==0 ? '元/小时' : item.taskType==1 ? '元/件' : item.taskType==2 ? '元/天' : ''}}）</text>
							</view>
							<view
								style="width: 1rpx;height: 50rpx;border-left: 1rpx solid #F5F5F5; margin-right: 1rpx;">
							</view>
							<view>
								<text>{{item.number}}</text>
								<text>雇员数（人）</text>
							</view>
						</view>
						<view>
							<image src="http://images.linglinggong.net/icon1/address.png" mode="aspectFill"></image>
							<text>{{getShowAdd(item.address)}}</text>
						</view>
						<view class="last-line">
							<view class="buttons">
								<view @click.stop="handleOpenModal(item.id)" class="button"> 一键发布 </view>
							</view>
						</view>
					</view>
					<uni-load-more :status="hasFlag ? 'loading' : isNoMore ? 'noMore' : ''"
						v-if="!isShowNullList&&tabflag" :style="{'background-color': hasFlag   ? '#FFF' : '#F2F2F2'}">
					</uni-load-more>
					<view class="hg-108" style="background-color: rgb(242, 242, 242);" v-if="!hasFlag"></view>
				</view>
			</view>
		</view>
		<hans-tabber :indexNum="1" :style="{position:'fixed',bottom:hansBarBottom+'rpx',left:'0px'}"></hans-tabber>
		<!-- 海报图 -->
		<!-- 分享海报 -->
		<!-- <view class="modal show" @touchmove.stop.prevent="()=>false" :style=" {display:isShowPost}"
			@click="onConfirmClicks">
			<canvas canvas-id="invitation-post"
				:style="{ width: '810rpx', height: '910rpx', position: 'fixed', top: '-9999px', left: '70rpx'}"></canvas>
			<view :style=" {display:isShowYhuiquan}" class="modal show" @touchmove.stop.prevent="()=>false">
				<view class="my-post2"> -->
		<!-- <view v-if="maxYhq>=10&&maxYhq<=20" class="my-post-bg-box"
						style="background-image: url(https://images.linglinggong.net/10-20yuan.png);">
						<view class="ss" style="height:67%" @click="closeClick(2)">
							<view class="inner">
								<view class="inner-left">
									<text style="color: #fff;font-size: 28rpx;">￥</text>
									<text style="margin-left: -4rpx;font-size: 58rpx;">{{maxYhq}}</text>
								</view>
								<view class="inner-right">
									<text style="font-size: 32rpx;padding-left: 8rpx;">{{maxYhq}}</text>
								</view>
							</view>
						</view>
						<image @click="closeClick(1)" style="left: 5%;top:5%;" class="close2"
							src="https://images.linglinggong.net/07.png">
						</image>
					</view>
					<view v-if="maxYhq>=5&&maxYhq<10" class="my-post-bg-box"
						style="background-image: url(https://images.linglinggong.net/5yuan.png);width: 93%;height: 760rpx;">
						<view class="ss" @click="closeClick(2)">
							<view class="inner"
								style="flex-direction: column;width: 60%;	padding-top: 0;height: 240rpx;">
								<view class="inner-top">
									{{maxYhq}}
								</view>
								<view class="inner-bottom">
									<text
										style="color: #CE7E40;font-size: 26rpx;margin-top: 10rpx;font-weight: 600;">￥</text>
									<text
										style="margin-left: 0rpx;color:#CE7E40;font-size: 48rpx;font-weight: 500;">{{maxYhq}}</text>
								</view>
							</view>
						</view>
						<image @click="closeClick(1)" class="close2" style="left:60rpx;top:60rpx;"
							src="https://images.linglinggong.net/07.png"></image>
					</view> -->
		<!-- <view v-if="maxYhq>=30" class="my-post-bg-box"
						style="background-image: url(https://images.linglinggong.net/30yishang.png);width: 93%;height: 730rpx;">
						<view class="ss" style="height: 75%;" @click="closeClick(2)">
							<view class="inner"
								style="flex-direction: column;width: 60%;	padding-top: 0;height: 240rpx;">
								<view class="inner-top" style="width: 51%;align-items: center;padding-bottom: 20rpx;">
									{{maxYhq}}
								</view>
								<view class="inner-bottom" style="width:84%;align-items: center;padding-bottom: 0rpx;">
									<text
										style="color: #FF3333;font-size: 28rpx;margin-top: 15rpx;font-weight: 600;">￥</text>
									<text
										style="color:#FF3333;font-size: 54rpx;font-weight: 600;margin-left: -4rpx;">{{maxYhq}}</text><text
										style="font-weight: 600;color:#FF3333;font-size: 42rpx;padding-left: 4rpx;">元</text>
								</view>
							</view>
						</view>
						<image @click="closeClick(1)" class="close2" style="left:30rpx;top:10rpx;"
							src="https://images.linglinggong.net/07.png"></image>
					</view> -->
		<!-- </view>
			</view>
		</view> -->
		<!-- 新人优惠  isNew-->
		<view class="modal show" @touchmove.stop.prevent="()=>false" :style=" {display: isNew}"
			@click="onConfirmClickNew">
			<canvas canvas-id="invitation-post"
				:style="{ width: '708rpx', height: '778rpx', position: 'fixed', top: '-9999px', left: '70rpx'}"></canvas>
			<view class="my-post" :style="{width: '708rpx', height: '778rpx'}">
				<image class="" src="https://images.linglinggong.net/newS.png"
					:style="{width: '708rpx', height: '778rpx'}" mode="aspectFit"></image>
				<view class="bgNew" @click="toNew()">
					<text>{{countNew}} </text>
				</view>
				<image @click="onCloseNew" class="close" src="https://images.linglinggong.net/07.png"></image>
			</view>
		</view>
		<lading v-if="isSHowloadingMask" ref="yaoqingAlert" :text="'正在前往结算订单...'"></lading>
		<!-- <view :style=" {display:showColloct}" class="modal show" @touchmove.stop.prevent="()=>false">
			<view class="my-post2">
				<view class="my-post-bg-box">
					<image class="my-post-bg" @click="closeClick(6)"
						src="https://images.linglinggong.net/collect-pop.png" style="width: 630rpx;height: 812rpx"
						mode="aspectFill"></image>
					<image @click="closeCollect" class="close2" style="left:-20rpx;top:-80rpx;"
						src="https://images.linglinggong.net/07.png">
					</image>
				</view>
			</view>
		</view> -->
		<!-- 邀请  isNew-->
		<!-- <view class="modal show" @touchmove.stop.prevent="()=>false" v-if="showNew" @click="onConfirmClickNew">
			<canvas canvas-id="invitation-post"
				:style="{ width: '708rpx', height: '778rpx', position: 'fixed', top: '-9999px', left: '70rpx'}"></canvas>
			<view class="my-post" :style="{width: '708rpx', height: '778rpx'}">
				<image class="my-post-bg" @click="toYaoqing()" src="https://images.linglinggong.net/yaoqingxinguzhu.png"
					style="width: 630rpx;height: 812rpx" mode="aspectFill"></image>
				<image @click="showNew=false" class="close" src="https://images.linglinggong.net/07.png"></image>
			</view>
		</view> -->
	</view>
</template>
<script>
	import hansTabber from '../../../components/hans-tabbar/hans-tabbar.vue'
	import {
		getTime,
		getName,
		getJob
	} from '../../../store/fakeInfo.js'
	import {
		isNewBoss,
		noSettlement
	} from '../../../libs/unit.js'
	import lading from '@/components/xjbg/loading.vue'
	export default {
		data() {
			return {
				showNew: true,
				isNew: 'none', //新雇员的活动
				bannerImgs: [], //banner图地址和点击地址
				tabflag: false, //切换选项卡
				dotsStyles: {
					width: '12',
					height: '12',
					backgroundColor: 'rgba(0, 0, 0, 0.3)',
					border: '0 solid',
					selectedBackgroundColor: '#FFFFFF',
					selectedBorder: '0 solid',
					bottom: '30'
				},
				currents: 0, //锚点
				userNum: '1500', //在线人数
				fakeInfo: ["1", "用户", "打包", ], //虚假信息
				setIntervalId: '', //setInterval id
				requestObj: {
					pageNum: 0,
					pageSize: 10,
					userId: '',
					status: '5',
					userId: '',
					isAsc: 'desc',
					orderByColumn: 'createTime',
				},
				userInfo: {
					user: {},
					params: {}
				}, //当前用户信息
				jobLists: [], //加了一个属性 showDay  显示的时间
				handleIsStop: true, // 是否允许切换
				hasFlag: true, //是否加载完成
				isShowNullList: false, //判断是不是没有发布过零工
				toDay: [], //获取今日时间
				isTabBarRed: false,
				isFullScreen: false, //是否是全面屏
				tabrHei: 0, //tabr高度
				isShowPost: 'none', //是否显示海报
				PopupWatchImg: {
					img: '',
					path: '',
				}, //弹窗图片对象 图片地址 跳转地址 宽 高
				iswhite: true,
				configBanner: [],
				timer: '',
				isSHowloadingMask: false,
				isNoMore: false,
				imgPath: uni.getStorageSync('imgPath'),
				showColloct: 'none', // 收藏雇员
				isShowYhuiquan: 'none',
				maxYhq: 0,
				redDot: false, //消息红点
			}
		},
		props: {
			hansBarBottom: {
				type: Number,
				default: 0
			}
		},
		// onLoad() {
		// 	this.DateMinus()
		// 	this.showColloctTime()
		// 	this.yaoqing()
		// 	console.log('邀请弹框')
		// 	// if(!uni.getStorageSync("popUp-show-time")){
		// 	// 	this.showNew = true;
		// 	// 	uni.setStorageSync("popUp-show-time")
		// 	// }
		// },
		methods: {
			// 邀请雇主一天谈一次
			yaoqing() {
				console.log('邀请弹框')
				let that = this
				let timer = uni.getStorageSync("popUp-show-time")
				if (!timer || new Date().getTime() - timer > 86400000) {
					that.showNew = true;
					uni.setStorageSync('popUp-show-time', new Date().getTime());
				} else {
					that.showNew = false;
				}
			},
			onConfirmClickNew() {
				this.isNew = 'none'
			},
			toYaoqing() {
				this.showNew = false
				uni.navigateTo({
					url: '/pages/invite-friend/new-boss-invite-friend'
				})
			},
			// 获取没有使用的优惠券列表
			async coupon_list() {
				let res = await this.$fetch(this.$api.coupon_list, {
					status: 0
				}, 'POST')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				if (res.rows.length > 0) {
					this.tempObj = res.rows.find(item => {
						return item.useType == 2
						// 回归
					})
					if (this.tempObj) {
						// console.log('22222')
						this.getArticleDetail(this.tempObj.huodong)
					} else {
						console.log('33333')
						this.tempObj = {}
						let temp2 = res.rows.map(item2 => {
							return item2.value
						})
						this.maxYhq = Math.max.apply(null, temp2)
						this.tempObj2 = res.rows.find(item3 => {
							return item3.value == this.maxYhq
						})
						// console.log(this.tempObj2)
						if (Object.keys(this.tempObj2).length !== 0 && this.isPopup618 == "none") {
							setTimeout(() => {
								this.isShowYhuiquan = ''
							}, 1000)
							this.actionOpt = 1
							// console.log(this.tempObj2)
						}
					}
				} else {
					this.getArticleDetail2()
				}
				// this.maxYhq = 5
			},
			// 关闭新手
			onCloseNew() {
				this.isNew = 'none'
			},
			closeCollect() {
				this.showColloct = 'none'
				this.showColloctTime()
			},
			closeClick(type) {
				if (type == 1) {
					this.isShowYhuiquan = 'none'
					uni.setStorageSync('date2', new Date().toISOString().slice(0, 10))
				}
				if (type == 2) {
					this.isShowYhuiquan = 'none'
					uni.setStorageSync('date2', new Date().toISOString().slice(0, 10))
					if (this.actionOpt == 0) {
						return
					}
					if (this.actionOpt == 1) {
						uni.navigateTo({
							url: '/pages/app-employer/send-job/send-job',
							animationType: 'fade-in',
							animationDuration: 100
						})
					}
					if (this.actionOpt == 2) {
						uni.navigateTo({
							url: '/pages/invite-friend/new-boss-invite-friend',
							animationType: 'fade-in',
							animationDuration: 100
						})
					}
				}
				if (type == 4) {
					this.newHand = 'none'
					uni.navigateTo({
						url: '/pages/app-employer/send-job/send-job',
						animationType: 'fade-in',
						animationDuration: 100
					})
				}
				if (type == 5) {
					this.isTimeGuzhu = 'none'
					uni.navigateTo({
						url: '/pages/employer-active/employer-active'
					})
				}
				if (type == 6) {
					this.showColloct = 'none'
					uni.navigateTo({
						url: '/pages/collect-active/collect-active?type=1'
					})
				}
			},
			DateMinus() { //date1:小日期   date2:大日期
				var sdate = new Date(uni.getStorageSync('userInfo').createTime);
				var now = new Date(Date.now());
				var days = now.getTime() - sdate.getTime();
				var day = parseInt(days / (1000 * 60 * 60 * 24));
				var nowDay = new Date()
				nowDay = nowDay.toLocaleDateString()
				if (day > 7) {
					if (uni.getStorageSync('guhzuTime')) {
						if (uni.getStorageSync('guhzuTime') != nowDay) {
							this.isTimeGuzhu = ''
							uni.setStorageSync('guhzuTime', nowDay)
						}
					} else {
						uni.setStorageSync('guhzuTime', nowDay)
						this.isTimeGuzhu = ''
					}
				}
			},
			async getConfigBanner() {
				let tempRegion
				// #ifdef H5
				tempRegion = '330783'
				// #endif
				tempRegion = uni.getStorageSync('region').slice(0, 6)
				let res = await this.$fetch(this.$api.bannerByToken, {
					region: tempRegion,
					bannerType: 1
				}, 'GET')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				this.configBanner = res.data
				console.log(this.configBanner, '1111111111111111111111111111111111');
			},
			tiaozhuan2(act) {
				if (act != "null") {
					uni.navigateTo({
						url: act
					})
				}
			},
			// 用户同意协议
			onConfirmClick() {
				uni.setStorageSync('first-is', true)
			},
			// 雇主弹窗
			async getBossPopupWatch() {
				// 雇主弹窗，判断雇主是否登录，登录及弹窗
				if (!uni.getStorageSync('guzhuShowColloct')) {
					if (uni.getStorageSync('token') !== '') {
						this.showColloct = 'block'
					}
				}
				let res = await this.$fetch(this.$api.property_list_by_type, {
					type: 1
				}, 'POST')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				this.isShowYhuiquan = ''
				this.YhuiquanImg = res.data.boss_popup_watch.split(",")
			},
			// 海报点击x，取消
			onConfirmClicks: function() {
				//	//console.log("wwwwwwwwwwwww")
				this.isShowPost = 'none' //是否显示海报
				uni.setStorageSync('date', new Date().toISOString().slice(0, 10))
				if (uni.getStorageSync('userType') == 1) {
					uni.navigateTo({
						url: '/pages/app-employer/send-job/send-job-new',
						animationType: 'fade-in',
						animationDuration: 100
					})
				}
			},
			// 用户不同意协议
			onCancelClick() {
				plus.runtime.quit();
			},
			//弹窗点击事件
			OnPopupWatch() {
				setTimeout(() => {
					uni.navigateTo({
						url: this.PopupWatchImg[1]
					})
				}, 200)
			},
			// 收藏弹窗推送,前一周每天弹一次,之后每两天弹一次
			async showColloctTime() {
				console.log('触发显示周期');
				let now = new Date()
				let nowHours = now.getHours()
				let nowMinutes = now.getMinutes()
				let nowSeconds = now.getSeconds()
				let nowTime = now.getTime()
				let natureDay = nowTime - nowHours * 60 * 60 * 1000 - nowMinutes * 60 * 1000 - nowSeconds * 1000
				if (!uni.getStorageSync('guzhuShowColloct')) {
					this.showColloct = ''
					uni.setStorageSync('guzhuShowColloct', natureDay)
					uni.setStorageSync('guzhuShowColloctFirstWeek', natureDay)
				} else {
					if (uni.getStorageSync('guzhuShowColloctFirstWeek') + (7 * 24 * 60 * 60 * 1000) > nowTime) {
						if (uni.getStorageSync('guzhuShowColloct') + (24 * 60 * 60 * 1000) < nowTime && nowTime < uni
							.getStorageSync('guzhuShowColloct') + (2 * 24 * 60 * 60 * 1000 - 1000)) {
							this.showColloct = ''
							uni.setStorageSync('guzhuShowColloct', natureDay)
						}
					} else {
						if (uni.getStorageSync('guzhuShowColloct') + (2 * 24 * 60 * 60 * 1000) < nowTime && nowTime <
							uni.getStorageSync('guzhuShowColloct') + (3 * 24 * 60 * 60 * 1000 - 1000)) {
							this.showColloct = ''
							uni.setStorageSync('guzhuShowColloct', natureDay)
						}
					}
				}
			},
			// 海报点击去发布
			handleClosePost() {
				this.isShowPost = 'none' //是否显示海报
				uni.setStorageSync('date', new Date().toISOString().slice(0, 10))
				uni.setStorageSync("userd", "5")
			},
			//判断是否是 刘海 全面屏
			setFullScreen() {
				if (plus.navigator.hasNotchInScreen()) {
					this.isFullScreen = true;
				} else {
					this.isFullScreen = false;
				}
			},
			tiaozhuan(path) {
				if (path != "null") {
					uni.navigateTo({
						url: path
					})
				}
			},
			change(e) {
				this.currents = e.detail.current
			},
			//获取banner
			async getBannerFunc() {
				let res = await this.$fetch(this.$api.property_list_by_type, {
					type: 1
				}, 'POST')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				var st = res.data.boss_banner.split(",")
				for (var i = 0; i < st.length; i++) {
					if (i % 2 == 0) {
						this.bannerImgs.push({
							'img': st[i],
							'path': st[i + 1]
						})
					}
				}
				console.log(this.bannerImgs, 'eeeeeeeeeeeeeeeeeee');
			},
			//获取在线人数
			async getUserListNum() {
				//console.log('加载人数')
				this.get_current_location()
				if ((new Date().getTime()) - uni.getStorageSync("userListNumTime") > 1800000) {
					let location = uni.getStorageSync('location')
					let res = await this.$fetch(this.$api.get_user_listnum, {
						lat: location[0],
						lng: location[1],
						region: uni.getStorageSync('region').slice(0, 6),
						token: uni.getStorageSync('token')
					}, 'POST')
					if (res.code) return uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					this.userNum = res.data
					uni.setStorageSync("UserListNum", this.userNum)
					uni.setStorageSync("userListNumTime", (new Date().getTime()))
					//console.log(uni.getStorageSync("userListNumTime"))
				} else {
					this.userNum = uni.getStorageSync("UserListNum")
				}
			},
			// 获取用户当前的经纬度
			get_current_location() {
				uni.getLocation({
					// #ifdef MP-WEIXIN || MP-TOUTIAO
					type: 'gcj02',
					// #endif
					success: (res) => {
						uni.setStorageSync('location', [res.latitude, res.longitude])
						this.getAdcode(res.latitude, res.longitude)
					}
				})
			},
			// 由经纬度查询街道的行政代码
			getAdcode(lat, lng) {
				uni.request({
					url: 'https://restapi.amap.com/v3/geocode/regeo?parameters',
					data: {
						key: 'd73cc951a96637a251a9a2446b48ce9c',
						location: lng + ',' + lat
					},
					success: res => {
						let region = res.data.regeocode.addressComponent.towncode.slice(0, 9)
						uni.setStorageSync('region', region)
						//console.log('首页的经纬度', uni.getStorageSync('location'), '获取区域region', uni.getStorageSync('region'))
						if (uni.getStorageSync('token')) {
							this.upd_user(lat, lng, region) //修改	
						}
					}
				})
			},
			//更新用户位置
			async upd_user(lat, lng, region) {
				//经纬度保留6位小数
				lat = parseFloat(lat).toFixed(6)
				lng = parseFloat(lng).toFixed(6)
				region = region.slice(0, 9)
				//console.log('更新用户位置', lat, lng, region)
				let res = await this.$fetch(this.$api.upd_user, {
					lat: lat,
					lng: lng,
					region: region
				}, 'POST')
				//console.log('更新用户位置res', res)
			},
			//获取虚假繁荣数据
			getFakeInfo() {
				if (!this.tabflag) {
					this.fakeInfo = []
					this.fakeInfo[0] = getTime()
					this.fakeInfo[1] = getName()
					this.fakeInfo[2] = getJob()
					this.fakeInfo[3] = getTime()
					this.fakeInfo[4] = getName()
					this.fakeInfo[5] = getJob()
					this.fakeInfo[6] = getTime()
					this.fakeInfo[7] = getName()
					this.fakeInfo[8] = getJob()
					////console.log(this.fakeInfo)
				}
			},
			//打开消息
			getMessage() {
				uni.navigateTo({
					url: '/pages/message/message-new'
				})
			},
			//点击发布任务呀
			async sendJob() {
				let res = await this.$fetch(this.$api.check_employer_real_name_certification, {
					region: uni.getStorageSync('region1') || 330782
				}, 'POST')
				console.log(res);
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				if (res.data) {
					uni.navigateTo({
						url: "/pages/real-name/real-name",
					})
				} else {
					uni.navigateTo({
						url: '/pages/app-employer/send-job/send-job',
						animationType: 'fade-in',
						animationDuration: 100
					})
				}
			},
			//获取我的零工
			async task_list() {
				//console.log('获取我的零工', this.hasFlag, this.handleIsStop)
				if (!this.hasFlag) return // 说明已经没有更多啦

				++this.requestObj.pageNum
				if (!this.handleIsStop) return uni.showToast({
					title: '你点击得太快啦~',
					icon: 'none'
				}) // 说明上一条请求结果未返回
				this.handleIsStop = false
				//console.log(this.userInfo)
				this.requestObj.userId = this.userInfo.userId
				// //console.log('获取我的零工 参数this.requestObj',this.requestObj)
				let res = await this.$fetch(this.$api.task_list, this.requestObj, 'POST')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				if (res.rows.length == 0) {
					this.isShowNullList = true
				} else {
					this.isShowNullList = false
				}
				//console.log('获取我发布的零工 res.rows[0]', res.rows[0])
				res.rows.forEach(item => {
					item.reward = item.reward.divide(100)
					item.floorsAmount = item.floorsAmount ? item.floorsAmount.divide(100) : 0
					item.showDay = this.isToDay(item.endTime)
					// //console.log('获取我的零工 item',item)
				})
				//console.log('获取我发布的零工1111 res.rows[0]', res.rows[0])
				uni.stopPullDownRefresh()
				this.handleIsStop = true
				this.jobLists = [...this.jobLists, ...res.rows]
				// //console.log('666', this.jobList)
				this.hasFlag = this.requestObj.pageSize * this.requestObj.pageNum < res.total
				this.iswhite = false
			},
			// 刷新
			refresh() {
				this.iswhite = true
				this.jobLists = []
				this.hasFlag = true
				this.requestObj.pageNum = 0
				this.requestObj.pageSize = 10
				this.task_list()
				//console.log("刷新了！~")
			},
			getShowAdd(add) {
				add = add.split('·')
				add.pop()
				return add.join('·')
			},
			//打开订单详情页
			handleOpenPage(id, taskStatus) {
				uni.navigateTo({
					url: '/pages/app-employer/boss-order-detail/boss-order-detail?id=' + id + '&taskStatus=' +
						taskStatus
				})
			},
			//一键发布
			handleOpenModal(taskId) {
				uni.navigateTo({
					url: '/pages/quickSendJob/invite?taskId=' + taskId + '&page=' + 2
				})
			},
			getJobList() {
				//console.log(getCurrentPages())
				this.refresh()
			},
			//判断时间 是不是 今天 昨天 过往 
			isToDay(times) {
				times = times.split(" ")
				let results = times[0]
				times = results.split("-")
				if (this.toDay[2] == times[2]) {
					results = "今天"
				}
				if (this.toDay[2] - times[2] == 1) {
					results = "昨天"
				}
				return results
			},
			//消息红点
			async get_push_message_records_red_dot() {
				let res = await this.$fetch(this.$api.get_push_message_records_red_dot, {}, 'GET')
				if (res.code) uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				this.redDot = res.data
			}
		},
		components: {
			hansTabber,
			lading,
		},
		computed: {
			'selectCity': function() {
				return this.$store.state.selectCity
			}
		},
		onPageScroll() {
			let query = uni.createSelectorQuery().in(this).select('.tabDiv')
			query.boundingClientRect(data => {
				////console.log("节点离页面顶部的距离为" + data.top);
				if (data.top == 0) {
					this.tabrHei = uni.getSystemInfoSync().statusBarHeight * 2
					//console.log(this.tabrHei)
				} else if (data.top != 0) {
					this.tabrHei = 0
				}
			}).exec();
		},
		onReachBottom() {
			this.task_list()
		},
		mounted() {
			this.getBossPopupWatch()
			this.yaoqing()
			this.get_push_message_records_red_dot()
		},
		onPullDownRefresh() {
			//监听用户下拉动作，一般用于下拉刷新
			this.iswhite = true
			this.refresh()
		},
		onShow() {
			if (this.timer == '') {
				this.timer = setInterval(() => {
					this.isTabBarRed = uni.getStorageSync("isTabBarRed")
				}, 200)
			}
		},
		onHide() {
			clearInterval(this.setIntervalId)
			clearInterval(this.timer)
		},
		created() {
			if (!uni.getStorageSync('first-is')) {
				//this.$refs.modal.showModal() // 显示			
			}
			if (new Date().toISOString().slice(0, 10) != uni.getStorageSync('date')) {
				uni.setStorageSync('sendjob-voice', false)
				this.isShowPost = 'none'
			}
			this.toDay = uni.getStorageSync("date").split("-")
			this.userInfo = uni.getStorageSync('userInfo')
			this.getConfigBanner()
			this.getUserListNum()
			this.getBannerFunc()
			this.getFakeInfo()
			//console.log("开始虚假繁荣")
			if (this.setIntervalId = '') {
				this.setIntervalId = setInterval(this.getFakeInfo, 5000)
			}
			if (uni.getStorageSync('isReboot') && uni.getStorageSync('token')) {
				uni.setStorageSync('isReboot', false)
				noSettlement().then(v => {
					if (v != 0) {
						this.isSHowloadingMask = true
						setTimeout(() => {
							this.isSHowloadingMask = false
							uni.navigateTo({
								url: `/pages/app-employer/boss-order-detail/boss-order-detail?id=${v}&taskStatus=7`
							})
						}, 2000)
					}
				})
			}
		}
	}
</script>
<style lang="less" scoped>
	// .container{
	// 	height: 100vh;
	// }
	.bg {
		height: 280rpx;
		display: flex;
		justify-content: flex-end;
		position: relative;
		overflow: hidden;

		//椭圆
		&::after {
			content: "";
			position: absolute;
			width: 200%;
			height: 260rpx;
			border-radius: 100%;
			left: -50%;
			top: -30rpx;
			background: #FCC928;
		}
	}

	.bgHead {
		width: 690rpx;
		height: 50rpx;
		margin-bottom: 30rpx;
		margin-top: 14rpx;
		z-index: 1;
		display: flex;
		justify-content: space-between;

		&>image {
			height: 50rpx;
			width: 50rpx;
			margin-right: 8rpx;
		}

		&>text {
			font-size: 32rpx;
			font-weight: bold;
			color: #402110;
			flex: 1;
		}
	}

	.banner {
		width: 750rpx;
		height: 240rpx;
		border-radius: 20rpx;
	}

	.swiper {
		width: 100%;
		height: 260rpx;

		swiper-item {
			image {
				display: block;
			}
		}
	}

	// swiper-item 里面的图片高度
	swiper-item image {
		width: 690rpx;
		height: 240rpx;
		margin: 0 auto;
		border-radius: 25rpx;
	}

	.tabDiv {
		background-color: #FFF;
		width: 750rpx;
		height: 88rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 30rpx;
		position: -webkit-sticky;
		position: sticky;
		top: var(--window-top);
		z-index: 99;
	}

	.tabLR {
		width: 345rpx;
		height: 88rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.tabLeft {
		.tabLR;
		// background-color: #F2F2F2;
		// border-radius: 12rpx 0 0 0;
	}

	.tabRight {
		.tabLR;
		// background-color: #FCC928;
		// border-radius: 0 12rpx 0 0;
	}

	.tabLeftImg {
		width: 132rpx;
		height: 33rpx;
	}

	.tabRightText {
		font-size: 32rpx;
		font-weight: 500;
		color: #402110;
		opacity: 0.5;
		line-height: 45rpx;
	}

	.tabLeftText {
		.tabRightText;
		//transform: rotateY(180deg);
	}

	.tabRightImg {
		.tabLeftImg;
		//transform: rotateY(180deg);
	}

	.jobList {
		width: 750rpx;
		display: flex;
		flex-flow: column;
		align-items: center;
	}

	.fakejobList {
		width: 690rpx;
		height: 60rpx;
		display: flex;
		justify-content: flex-start;
	}

	.fakeJob {
		width: 364rpx;
		height: 60rpx;
		background: rgba(120, 120, 120, 0.2);
		border-radius: 4rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #402110;
		line-height: 60rpx;
		padding-left: 26rpx;
		opacity: 0;
	}

	.anim-opacity {
		animation: opacity 3s 2.6s infinite;
	}

	.anim-opacity1 {
		animation: opacity 3s 3.2s infinite;
	}

	.anim-opacity2 {
		animation: opacity 3s 3.8s infinite;
	}

	@keyframes opacity {
		0% {
			opacity: 0;
			transform: translateY(180rpx);
		}

		30% {
			opacity: 1;
		}

		100% {
			opacity: 0;
			transform: translateY(0rpx);
		}
	}

	.jobLogo {
		width: 690rpx;
		height: 260rpx;
		background: #FCC928;
		box-shadow: 0px 20rpx 20rpx 0rpx rgba(252, 201, 40, 0.2);
		border-radius: 12rpx;
		margin-top: 190rpx;
		display: flex;
		justify-content: center;

		&>view {
			width: 610rpx;
			height: 160rpx;
			margin-top: 80rpx;
			display: flex;
			justify-content: space-between;

			&>view {
				display: flex;
				flex-flow: column;

				&>text:first-child {
					font-size: 48rpx;
					font-weight: bold;
					color: #402110;
					line-height: 45rpx;
				}

				&>text:last-child {
					font-size: 26rpx;
					font-weight: 400;
					color: #402110;
					line-height: 45rpx;
					margin-top: 20rpx;
				}
			}

			&>image {
				width: 138rpx;
				height: 139rpx;
			}
		}
	}

	.aroundPeople {
		width: 280rpx;
		height: 143rpx;
		margin-top: 50rpx;
		display: flex;
		flex-flow: column;
		align-items: center;
		margin-bottom: 140rpx;

		.aroundPeopleTestNum {
			font-size: 58rpx;
			font-weight: 400;
			color: #FD8622;
			line-height: 60rpx;
		}

		.aroundPeopleTest {
			font-size: 30rpx;
			font-weight: 400;
			color: #402110;
			line-height: 60rpx;
		}
	}

	.job-info {
		margin-top: 30rpx;
		width: 630rpx;
		//height: 400rpx;
		border-radius: 12rpx;
		position: relative;
		display: flex;
		flex-direction: column;
		background-color: #FFFFFF;
		padding: 36rpx 30rpx 40rpx 30rpx;

		&>view {
			display: flex;
		}

		&>view:nth-child(1) {
			justify-content: space-between;
			margin-bottom: 36rpx;
			align-items: center;

			&>view {
				display: flex;

				&>text:nth-child(2) {
					margin-left: 20rpx;
					color: #3E220A;
					line-height: 40rpx;
					font-weight: bold;
					font-size: 36rpx;
					letter-spacing: 0;
				}
			}

			&>.status {
				font-size: 24rpx;
				height: 36rpx;
				border-radius: 8rpx;

				.default {
					color: #AAAAAA;
					background: #F5F5F5;
					border-radius: 8rpx;
					font-size: 24rpx;
					width: 150rpx;
					text-align: center;
				}

				.jintian {
					background: #FEF4D4;
					color: #FCC928;
					font-size: 24rpx;
					width: 60rpx;
					height: 36rpx;
					border-radius: 8rpx;
					text-align: center;
				}

				.zuotian {
					background: #EFFAF7;
					color: #2DC89E;
					font-size: 24rpx;
					width: 60rpx;
					height: 36rpx;
					border-radius: 8rpx;
					text-align: center;
				}

				&>text {
					margin: auto;
				}
			}
		}

		&>view:nth-child(2) {
			display: flex;
			justify-content: space-around;
			margin-bottom: 36rpx;
			height: 90rpx;

			&>view:nth-child(1) {
				display: flex;
				align-items: center;
				flex-direction: column;
				height: 89rpx;

				&>text:nth-child(1) {
					font-size: 48rpx;
					margin-bottom: 24rpx;
					line-height: 45rpx;
				}

				&>text:nth-child(2) {
					font-size: 24rpx;
					color: #A5A5A5;
				}
			}

			&>view:nth-last-child(1) {
				display: flex;
				align-items: center;
				flex-direction: column;
				height: 89rpx;

				&>text:nth-child(1) {
					font-size: 48rpx;
					margin-bottom: 24rpx;
					line-height: 45rpx;
				}

				&>text:nth-child(2) {
					font-size: 24rpx;
					color: #A5A5A5;
				}
			}
		}

		&>view:nth-child(3) {
			// border: 1px solid #000000;
			// height: 34rpx;
			background: #F5F5F5;
			border-radius: 8rpx;
			min-height: 48rpx;
			display: flex;
			margin-top: 20rpx;
			margin-bottom: 36rpx;
			font-size: 24rpx;
			color: #000000;
			letter-spacing: 0;

			&>image {
				align-self: center;
				width: 32rpx;
				height: 32rpx;
				margin-right: 10rpx;
				margin-left: 10rpx;
			}

			&>text {
				margin: auto 0;
			}
		}

		&>.last-line {
			display: flex;
			align-items: center;
			justify-content: flex-end;

			&>.buttons {
				// border: 1px solid #000000;
				display: flex;
				align-self: flex-end;

				&>.button {
					width: 188rpx;
					height: 68rpx;
					border-radius: 8rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 24rpx;

					&:active {
						opacity: 0.7;
					}
				}

				.button:nth-child(1) {
					background: #FCC928;
					margin-left: 30rpx;
					color: #402110;
				}
			}
		}
	}

	.redD {
		background-color: #FE4B28;
		position: relative;
		left: 48rpx;
		top: 2rpx;
		z-index: 1;
		width: 12rpx;
		height: 12rpx;
		border-radius: 50%;
		background-color: #F85A41;
		box-shadow: rgba(248, 90, 65, 0.50) 0 2rpx 6rpx 2rpx;
	}

	.anim-redD {
		animation: 2s redD 0s infinite;
	}

	@keyframes redD {
		0% {
			transform: translateY(0);
		}

		30% {
			transform: translateY(-15rpx);
		}

		40% {
			transform: translateY(0);
		}

		50% {
			transform: translateY(-10rpx);
		}

		70% {
			transform: translateY(0rpx);
		}

		80% {
			transform: translateY(-5rpx);
		}

		100% {
			transform: translateY(0);
		}
	}

	.modal {
		z-index: 9;
		width: 100vw;
		height: calc(100vh - var(--status-bar-height) + 192rpx);
		pointer-events: none;
		background: transparent;
		transition: all .3s;
		position: fixed;
		top: 0;
		padding-top: calc(var(--status-bar-height) + 16rpx);
		z-index: 3333;
		background-color: #FFFFFF;

		&.show {
			display: flex;
			width: 100%;
			height: 100%;
			top: 0rpx;
			background: rgba(0, 0, 0, 0.40);
			pointer-events: auto;
			text-align: center;
			z-index: 9999;
		}

		.my-post {
			// border: 1px solid  #4CD964;
			position: absolute;
			top: 0rpx;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
			width: 400rpx;
			height: 400rpx;

			.my-post-bg {
				width: 400rpx;
				height: 400rpx;
				display: inline-block;
			}
		}

		.close {
			position: absolute;
			left: 0;
			top: -100rpx;
			width: 70rpx;
			height: 70rpx;
			z-index: 111;
		}
	}

	.statusBarHeight {
		height: calc((var(--status-bar-height))/2);
		background-color: #FCC928;
	}

	.faburenwu_bg {
		background-color: #FFF;
		// position: fixed;
		// top: 0;
		// left: 0;
	}

	.lishifabu_bg {
		background-color: #FFF;
	}

	.my-post2 {
		width: 100%;
		height: 100vh;
		display: flex;
		justify-content: center;
		align-items: center;

		.my-post-bg-box {
			position: relative;
			width: 630rpx !important;
			height: 680rpx !important;
			background-size: 100% 100%;
			background-repeat: no-repeat;
			display: flex;
			justify-content: center;
			align-items: center;

			.ss {
				width: 100%;
				height: 55%;
				display: flex;
				justify-content: center;
				align-items: center;
				// border: 1px solid;
			}

			.inner {
				width: 480rpx;
				height: 400rpx;
				padding-top: 60rpx;
				display: flex;
				justify-content: center;
				align-items: center;

				// border: 1px solid;
				.inner-top {
					width: 41%;
					height: 50%;
					display: flex;
					justify-content: flex-start;
					align-items: flex-start;
					padding-top: 18rpx;
					color: #F39B19;
					font-size: 34rpx;
					font-weight: 400;
					// margin-left: -100rpx;
					// border: 1px solid;
				}

				.inner-bottom {
					display: flex;
					justify-content: flex-start;
					align-items: center;
					width: 88%;
					height: 50%;
					padding-bottom: 60rpx;
					// padding-left: 50rpx;
					// border: 1px solid;
				}

				// border: 1px solid;
				.inner-left {
					padding-top: 20rpx;
					width: 35%;
					// border: 1px solid;
					font-size: 56rpx;
					color: #fff;
					font-weight: 600;
				}

				.inner-right {
					flex: 1;
					display: flex;
					justify-content: flex-start;
					align-items: center;
					padding-left: 65rpx;
					font-weight: 400;
					color: #FF6600;
					// border: 1px solid;
					// color: red;
				}
			}

			.close2 {
				position: absolute;
				left: 0;
				top: 0;
				width: 70rpx;
				height: 70rpx;
				// border: 1px solid;
				z-index: 9999999999;
			}
		}

		// display: inline-block;
	}
</style>